﻿IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[vw_UserProfile]'))
BEGIN
	declare @sql nvarchar(4000)
	SET @sql = 'ALTER VIEW [dbo].[vw_UserProfile]
    AS
    SELECT p.*, u.[UserId], u.[Name], u.[LastLockedOutDate], u.[IsLockedOut], u.[PasswordQuestion], u.[PasswordAnswer], u.[Comment], u.[LastPasswordChangedDate], u.[IsApproved], u.[LastActivityDate], u.[Email], u.[Password], u.[Salt], u.[PasswordFormat]
    FROM dbo.vw_gen_MedianamikProfile AS p INNER JOIN
        dbo.medianamik_User AS u ON p.[User] = u.UserId
        where p.generation = -1 and culturename = '''''
						  
	exec sp_executesql @sql

END